<%@page import="dto.companyFormDTO"%>
<%@page import="vo.companyFormVO"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../css/company_form.css"/>
<script src = '../js/form.js'></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">
$(function() {
	$("#datepicker1").datepicker(
			{
				changeMonth : true,
				dayNamesMin : [ '월', '화', '수', '목', '금', '토', '일' ],
				monthNamesShort : [ '1', '2', '3', '4', '5', '6', '7', '8',
						'9', '10', '11', '12' ],
				"dateFormat" : "yymmdd"
			});
	$("#datepicker2").datepicker(
			{
				changeMonth : true,
				dayNamesMin : [ '월', '화', '수', '목', '금', '토', '일' ],
				monthNamesShort : [ '1', '2', '3', '4', '5', '6', '7', '8',
						'9', '10', '11', '12' ],
				"dateFormat" : "yymmdd"
			});
});

</script>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="vo" class="vo.companyFormVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>
<%

	System.out.println("vo에 저장된 form_number " + vo.getForm_number());
	System.out.println("vo에 저장된 변수 이름 " + vo.getE_name());
	System.out.println("vo에 저장된 변수 1 " + vo.getC_draft_approbator_1());
	System.out.println("vo에 저장된 변수 2 " + vo.getC_draft_approbator_2());
	System.out.println("vo에 저장된 변수 3 " + vo.getC_draft_approbator_3());
	System.out.println("vo에 저장된 변수 4 " + vo.getC_draft_approbator_4());
	System.out.println("vo에 저장된 변수 5 " + vo.getC_draft_approbator_5());
	System.out.println("vo에 저장된 변수 폼 번호 " + vo.getC_form_number());
	System.out.println("vo에 저장된 변수 날자 " + vo.getC_draft_date());
	System.out.println("vo에 저장된 변수 시작 날자 " + vo.getC_draft_start_date());
	System.out.println("vo에 저장된 변수 종료 날자 " + vo.getC_draft_end_date());
	
	

	String m_id = (String) session.getAttribute("sessionMid");

	System.out.print("m_id : " + m_id);
	companyFormVO cvo = vo;

	companyFormDTO cdto = new companyFormDTO();

	if(vo.getForm_number() == 0){
		cvo.setM_id(m_id);
	
		cvo = cdto.find_number(cvo);
	}

	cdto.voSet(cvo);
	
	ArrayList<Long> al = cdto.member_list(cvo.getM_id());
	String timeStamp = cvo.getC_draft_date();
	String form_number = cvo.getC_form_number();
	if(vo.getForm_number() == 0){
		timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm")
				.format(Calendar.getInstance().getTime());
		form_number = new SimpleDateFormat("yyyyMM").format(Calendar
				.getInstance().getTime());
	
		if (cvo.getC_form_number() == null) {
			cvo.setC_form_number(cvo.getD_tname() + form_number);
			cvo.setC_draft_date(timeStamp);
			cvo.setC_draft_start_date(" ");
			cvo.setC_draft_end_date(" ");
			cvo.setC_draft_title(" ");
			cvo.setC_draft_context(" ");
		}
	}
%>


	<div id="top">
	</div>
	<div id="payment" align="center">		
	<h1>결제보고서</h1>
	<form name="frm" method="post">
	
	<input type='hidden' name="form_number"  value="<%=cvo.getForm_number()%>" />
	
	<input type='hidden' name="m_id"  value="<%=cvo.getM_id()%>" />
	
	<input type='hidden' name="c_form_number"  value="<%=cvo.getD_tname()%>
	<%if(cvo.getForm_number() == 0){out.print(form_number);}%>" />
	
	<input type='hidden' name="c_draft_date" value="<%=timeStamp%>" />
	
	<input type='hidden' name="e_name" value="<%=cvo.getE_name()%>"/>
	<input type='hidden' name="e_number" value="<%=cvo.getE_number()%>"/>
	<input type='hidden' name="e_position" value="<%=cvo.getE_position()%>"/>
	<input type='hidden' name="d_tname" value="<%=cvo.getD_tname()%>"/>
	
	<input type='hidden' name="c_draft_approbator_1" value="<%=cvo.getC_draft_approbator_1()%>"/>
	<input type='hidden' name="c_draft_approbator_2" value="<%=cvo.getC_draft_approbator_2()%>"/>
	<input type='hidden' name="c_draft_approbator_3" value="<%=cvo.getC_draft_approbator_3()%>"/>
	<input type='hidden' name="c_draft_approbator_4" value="<%=cvo.getC_draft_approbator_4()%>"/>
	<input type='hidden' name="c_draft_approbator_5" value="<%=cvo.getC_draft_approbator_5()%>"/>
	
	
	
	<table class="table_head" width="650" align="center" border="0" cellpadding="4" cellspacing="0" bordercolor="#000" >
		<tr>
			<td>
				<table class="table_item1" cellSpacing=0 cellPadding=0 width="100%" border=1>
					<tbody>
						<TR>
							<TD class="form_item1" width= 15%> &nbsp; 품의번호</TD>
							<TD class="form_item2" width= 35%> &nbsp;<%=cvo.getC_form_number() %>-</TD>
							<TD class="form_item1" width= 15%> &nbsp; 신청구분</TD>
							<TD class="form_item2" width= 35%>&nbsp; 
											<select name="c_form_type">
												<option value="1">결제 요청</option>
												<option value="2">업무 이관</option>
												<option value="3">기획서</option>
												<option value="4">구매 이력서</option>
											</select>
									</TD>
						</TR>
				
						<TR>
							<TD class="form_item1">&nbsp; 기안일자 </TD>
							<TD class="form_item2">&nbsp; <%=cvo.getC_draft_date() %> </TD>
							<TD class="form_item1">&nbsp; 기안부서 </TD>
							<TD class="form_item2">&nbsp;<%=cvo.getD_tname() %></TD>
						</TR>
				
						<TR>
							<TD class="form_item1">&nbsp; 기안자 </TD>
							<TD class="form_item2">&nbsp; <%=cvo.getE_name() %> </TD>
							<TD class="form_item1">&nbsp; 업무기간 </TD>
							<TD class="form_item2">&nbsp;
								<input type="text" id="datepicker1" name="c_draft_start_date" size="6" value="<%=cvo.getC_draft_start_date()%>"> &nbsp;~
								<input type="text" id="datepicker2" name="c_draft_end_date" size="6" value="<%=cvo.getC_draft_end_date()%>"> &nbsp;
							</TD>
						</TR>
			
						<TR>
							<TD class="form_item1">&nbsp; 시 행 자 </TD>
							<TD class="form_item1" colSpan=3>
<!-- 								<table class='table_item2' width='100%'> -->
<!-- 									<tr> -->
<!-- 										<td style='padding:4px; padding-left:8px;'> -->
											<%=cvo.getE_name() %> 
<!-- 										</td> -->
<!-- 									</tr> -->
<!-- 								</table> -->
							</TD>
						</TR>
						
<!-- 						<TR> -->
<!-- 							<TD class="form_item1">&nbsp; 수신참조  </TD> -->
<!-- 							<TD class="form_item1" colSpan=3> -->
<!-- 								<table class='table_item2' width='100%'> -->
<!-- 									<tr> -->
<!-- 										<td style='padding:4px; padding-left:8px;'> -->
<!-- 											<input type="text" class="employees_select" readonly name="request_name">&nbsp;선택  -->
<!-- 										</td> -->
<!-- 									</tr> -->
<!-- 								</table> -->
<!-- 							</TD> -->
<!-- 						</TR> -->
						
						<TR>
							<TD class="form_item1">&nbsp; 결 &nbsp; &nbsp; 재  </TD>
							<TD class="form_item6" colSpan=3>
								<span id='approval_line_html'>
									<table width='100%' height='100'>
									<tr height='20px'>
										<td width=16% align='center' style='border-right:0; border-bottom:1px solid #d5d5d5; text-align:center'
										 onmousedown="PopLayer.action('layer',1)">&nbsp;
										<%if(cvo.getC_draft_approbator_1() == 0){ %>
											<a href="#" class="lect">결제자 등록 </a>
										<%}else{ out.print(cdto.user_name(cvo.getC_draft_approbator_1())); }%></td>
										
										<td width=16% class="lect" onmousedown="PopLayer.action('layer',2)" >&nbsp; 
										<%if(cvo.getC_draft_approbator_2() == 0){ %>
											<a href="#" >결제자 등록 </a>
										<%}else{ out.print(cdto.user_name(cvo.getC_draft_approbator_2())); }%></td>
										
										<td width=16% class="lect" onmousedown="PopLayer.action('layer',3)" >&nbsp; 
										<%if(cvo.getC_draft_approbator_3() == 0){ %>
											<a href="#" >결제자 등록 </a>
										<%}else{ out.print(cdto.user_name(cvo.getC_draft_approbator_3())); }%></td>
										
										<td width=16% class="lect" onmousedown="PopLayer.action('layer',4)" >&nbsp; 
										<%if(cvo.getC_draft_approbator_4() == 0){ %>
											<a href="#" >결제자 등록 </a>
										<%}else{ out.print(cdto.user_name(cvo.getC_draft_approbator_4())); }%></td>
										
										<td width=16% class="lect" onmousedown="PopLayer.action('layer',5)" >&nbsp; 
										<%if(cvo.getC_draft_approbator_5() == 0){ %>
											<a href="#" >결제자 등록 </a>
										<%}else{ out.print(cdto.user_name(cvo.getC_draft_approbator_5())); }%></td>
									</tr>
									<tr height='94px'>
										<td align='center' valign='top' style='border-right:0; border-bottom:0;'>&nbsp;</td>
										<td class="lect2" align='center' valign='top'>&nbsp;</td>
										<td class="lect2" align='center' valign='top'>&nbsp;</td>
										<td class="lect2" align='center' valign='top'>&nbsp;</td>
										<td class="lect2" align='center' valign='top'>&nbsp;</td>
									</tr>
									</table>
								</span> 
							</TD>
						</TR>
						
<!-- 						<TR> -->
<!-- 							<TD class="form_item1">&nbsp; 합 &nbsp; &nbsp; 의  </TD> -->
<!-- 							<TD class="form_item6" colSpan=3> -->
<!-- 								<span id='approval_line_html'> -->
<!-- 								<table width='100%' height='100'> -->
<!-- 									<tr height='20px'> -->
<!-- 										<td width=16% align='center' style='border-right:0; border-bottom:1px solid #d5d5d5; text-align:center'>&nbsp;</td> -->
<!-- 										<td width=16% class="lect">&nbsp;</td> -->
<!-- 										<td width=16% class="lect">&nbsp;</td> -->
<!-- 										<td width=16% class="lect">&nbsp;</td> -->
<!-- 										<td width=16% class="lect">&nbsp;</td> -->
<!-- 									</tr> -->
<!-- 									<tr height='94px'> -->
<!-- 										<td align='center' valign='top' style='border-right:0; border-bottom:0;'>&nbsp;</td> -->
<!-- 										<td class="lect2" align='center' valign='top'>&nbsp;</td> -->
<!-- 										<td class="lect2" align='center' valign='top'>&nbsp;</td> -->
<!-- 										<td class="lect2" align='center' valign='top'>&nbsp;</td> -->
<!-- 										<td class="lect2" align='center' valign='top'>&nbsp;</td> -->
<!-- 									</tr> -->
<!-- 								</table> -->
<!-- 								</span>  -->
<!-- 							</TD> -->
<!-- 						</TR> -->
						
						<TR>
							<TD class="form_item1">&nbsp; 제 &nbsp; &nbsp; 목 </TD>
							<TD class="form_item1" colSpan=3>&nbsp;
								<input type="text" name="c_draft_title" class="title" value="<%=cvo.getC_draft_title() %>" maxlength="100"/>
							</TD>
						</TR>
						<TR>
							<TD class="form_item1">&nbsp; 내 &nbsp; &nbsp; 용 </TD>
							<TD class="form_item1" colSpan=3>&nbsp;
								<textarea name="c_draft_context" class="contents"  ><%=cvo.getC_draft_context()%></textarea>
							</TD>
			
						</TR>
					</tbody>
				</table>
			</td>
		</tr>
	</table>	
	<%if(cvo.getForm_number() == 0){ %>
	<input type="button"  value="작성 완료"  onclick="finish(1)">
	<%} else { %>
	<input type="button"  value="수정 완료"  onclick="finish(4)">
	<%} %>
	</form>
</div>
<div id="layer" style="border: solid 1px #8C8C8C; width: 200px; height: 200px; display:none; position:absolute; left:0; top:0; padding: 10px; background-color: #F6F6F6; font-size:12px; font-family: 돋움; color: black; width: 180px; height: 265px;">
	<ul>
	<%
	for(int i = 0; i<al.size(); i++){
	%>
	
		<li><a href="#" onclick="rediract_this(<%=al.get(i)%>)"><%=cdto.user_name(al.get(i)) %></a></li>
	
	<%}%>
	</ul>
	<input type="button" value="close"  onclick="PopLayer.close()"/>
</div>
</body>
</html>